home *** CD-ROM | disk | FTP | other *** search
- Path: solon.com!not-for-mail
- From: thads@csn.net (Thad Smith)
- Newsgroups: comp.lang.c,comp.lang.c.moderated,hp.unix,comp.sys.hp.apps,comp.sys.hp.hpux
- Subject: Re: C coding problem
- Date: 8 Apr 1996 22:50:57 -0500
- Organization: T3 Systems
- Sender: clc@solutions.solon.com
- Approved: clc@solutions.solon.com
- Message-ID: <4kcmr1$p6e@solutions.solon.com>
- References: <4j06na$808@solutions.solon.com> <4jttan$3gf@solutions.solon.com>
- <4jv6st$crf@solutions.solon.com> <4k1qh3$5hn@solutions.solon.com>
- Reply-To: ThadSmith@acm.org
- NNTP-Posting-Host: solutions.solon.com
-
- In article <4kbdq6$ec2@solutions.solon.com>,
- VArase@varase.it.luc.edu (Verne Arase) wrote:
- >In article <4k5vrk$a2d@solutions.solon.com>,
- >schwarz@mips.complang.tuwien.ac.at (Konrad Schwarz) wrote:
- >
- > >|> In such and environment,
- > >|> *q++ = *p++;
- > >|> loses badly to
- > >|> q[i] = p[i], ++i;
- > >|> if the hardware indexing works in terms of the objects being
- > >|> referenced.
- > >
- > >Note that indexed addressing often works only for small
- > >powers of two, e.g., x86 family.
- >
- >Why only small powers of two? You mean if the size of each element is a
- >small power of two (so you can use shift rather than multiply)?
-
- The x86 family implements indexing of the form q[regi*4] (not sure
- about syntax), in which the processor performs the multiply by power
- of two at the time of address generation. This is quicker than
- performing a separate multiply instruction before the indexed
- instruction.
-
- Other sizes require explicit mutiplication of indices, separate
- maintenance of i*4, or conversion to pointer operations.
-
- Thad
-